package com.tuanzhang.zhw.rpc.spring;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.core.type.filter.AnnotationTypeFilter;

import java.lang.annotation.Annotation;


/**
 * 自定义路径扫描 加载类
 */
public class RpcClassPathScanner extends ClassPathBeanDefinitionScanner {


    public RpcClassPathScanner(BeanDefinitionRegistry registry, Class<? extends Annotation> annType) {
        super(registry);
        //只拦截指定的注解
        super.addIncludeFilter(new AnnotationTypeFilter(annType));
    }

    @Override
    public int scan(String... basePackages) {
        return super.scan(basePackages);
    }
}
